# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo7_06
# Description:
# Author:       asus
# Date:         2019/3/7
#-------------------------------------------------------------------------------


#初始化函数
def init(data):
    data["d"] = {}
    data["names"] = []
    data["products"] = []
#flag为True转化为列表，为False转化为字典
#msg表示提示文本
def inputListOrDict(flag,msg):
    print(msg)
    inputStr = input(":")
    list = inputStr.split(",")#将字符用逗号拆分成列表
    if flag:
        return list
    else:
        keys = []
        values = []
        for i in range(len(list)):
            if i % 2 == 0:
                keys.append(list[i])
            else:
                values.append(list[i])
    return dict(zip(keys, values))








#输出字典中的数据
def outDict(data):
    for key in data.keys():
        print(key,":",data[key])

data1 = {}
data2 = {}
init(data1)
init(data2)
data1["d"].update(inputListOrDict(False,"请输入字典数据,key和value之间用逗号分隔"))
data1["names"].extend(inputListOrDict(True,"请输入姓名，多个姓名请用逗号分隔"))
data1["products"].extend(inputListOrDict(True,"请输入产品，多个产品之间用逗号分隔"))
data2["d"].update(inputListOrDict(False,"请输入字典数据,key和value之间用逗号分隔"))
data2["names"].extend(inputListOrDict(True,"请输入姓名，多个姓名请用逗号分隔"))
data2["products"].extend(inputListOrDict(True,"请输入产品，多个产品之间用逗号分隔"))
outDict(data1)
outDict(data2)